package com.ylxn.sqlSession;

import com.ylxn.config.XMLConfigurationBuilder;
import com.ylxn.pojo.Configuration;

import java.io.InputStream;

public class SqlSessionFactoryBuilder {

    public static SqlSessionFactory build(InputStream inputStream) throws Exception {
        //1,使用dom4j解析inputStream，将解析出来的内容封装到Configuration对象中
        Configuration configuration  = new XMLConfigurationBuilder().parseConfig(inputStream);

        //2,创建SqlSessionFactory对象。工厂类，主要负责创建SqlSession（工厂模式）
        DefaultSqlSessionFactory defaultSqlSessionFactory = new DefaultSqlSessionFactory(configuration);
        return defaultSqlSessionFactory;
    }
}
